package io.g740.handler;

import io.g740.service.MigrationConfig;
import io.g740.util.Constants;
import io.g740.util.SqlUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.sql.Connection;
import java.sql.SQLException;

/**
 * 数据迁移处理器
 *
 * @author YunKaiLuo
 * @date 2024/10/22
 */
public class FullQuantityNotReservedDataMigrationHandler extends FullQuantityReservedDataMigrationHandler {

    private static final Logger log = LoggerFactory.getLogger(FullQuantityNotReservedDataMigrationHandler.class);

    @Override
    public boolean migrate(MigrationConfig migrationConfig, Connection sourceConn, Connection targetConn) throws SQLException {
        // 先删除目标表中的所有数据
        SqlUtil.execute(targetConn, Constants.getTruncateTable(
                migrationConfig.getTargetTableInfo().getName()));

        return super.migrate(migrationConfig, sourceConn, targetConn);
    }
}
